/*
 *    Copyright (c) 2018-2025, 云集汇通 All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the yunjihuitong.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 */

package com.yjht.modules.sys.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;

/**
 * 系统页面视图
 *
 * @author lengleng
 * @email wangiegie@gmail.com
 * @date 2016年11月24日 下午11:05:27
 */
@Controller
public class SysPageController {
    /**
     * 默认跳转，支持 模块、页面
     *
     * @param module 模块
     * @param url    页面
     * @return page
     */
    @GetMapping("modules/{module}/{url}.html")
    public String module(@PathVariable("module") String module, @PathVariable("url") String url) {
        return "modules/" + module + "/" + url;
    }

    /**
     * 默认跳转，支持 模块、功能、页面
     *
     * @param module 模块
     * @param func   功能
     * @param url    页面
     * @return page
     */
    @GetMapping("modules/{module}/{func}/{url}.html")
    public String moduleExt(@PathVariable("module") String module, @PathVariable("func") String func, @PathVariable("url") String url) {
        return "modules/" + module + "/" + func + "/" + url;
    }

    /**
     * 主页
     *
     * @return page
     */
    @GetMapping(value = {"/", "index.html"})
    public String index() {
        return "index";
    }

    /**
     * 登录页
     *
     * @param captcha 是否开启验证码
     * @param request request
     * @return page
     */
    @GetMapping("login.html")
    public String login(@Value("${lims.captcha.enabled}") boolean captcha, HttpServletRequest request) {
        request.setAttribute("captcha", captcha);
        return "login";
    }

    /**
     * 首页main
     *
     * @return page
     */
    @GetMapping("main.html")
    public String main() {
        return "main";
    }

    /**
     * 404页面
     *
     * @return page
     */
    @GetMapping("404.html")
    public String notFound() {
        return "404";
    }

}
